<include file="Common:header" />
<TYjs file='fix_table_title'/>
<div class="table_content">
        <table class="list_table">
            <tr>
                <th style="min-width:100px;">優惠券名</th>
                <th style="min-width:80px;">優惠券類型</th>
                <th style="min-width:80px;">獲取方式</th>
                <th width="80px">減免金額</th>
                <th width="190px">開始時間</th>
                <th width="190px">結束時間</th>
                <th width="190px">创建时间</th>
                <th width="130px">操作</th>
            </tr>
            <foreach name='list' item='vo'>
                <tr>
                    <td>
                    	{$vo.name}
                    </td>
                    <td><if condition="$vo.type eq 1">直接優惠</if></td>
                    <td>
                        <switch name="vo['get_type']">
                                <case value="0">通過分享</case>
                                <case value="1">通過註冊</case>
                                <case value="2">通過活動</case>
                                <default>不知類型
                        </switch>
                    </td>
                    <td>{$vo.price}元</td>
                    <td>{$vo.start_time|date="Y-m-d H:i",###}</td>
                    <td>{$vo.end_time|date="Y-m-d H:i",###}</td>
                    <td>{$vo.create_time|date="Y-m-d H:i",###}</td>
                    <td>
                    <a class="a_btn add_server_name" coupon_id="{$vo['id']}" style="margin:10px;cursor:pointer;">發送</a>
                       <!--  <a class="edit" href="{:U(MODULE_NAME.'/Post/edit_post',array('id'=>$vo['id'],'type'=>'edit'))}" title="编辑"></a> -->
                        <a class="delete" href="{:U(MODULE_NAME.'/coupon/delete_coupon',array('id'=>$vo['id']))}" title="删除"></a>
                    </td>
                </tr>
            </foreach>
        </table>
     <div id="add_name" style="display:none;">
	     <form method="post" id="upForm">
	        <table class="edit_table">
	        	<tr>
	                <td class="tablehead">用戶手機號</td>
	                <td>
	                <span class="radio">
						<input type="radio" id="radio2" name="get_type" value="1"/><label for="radio2">全選</label>
                        <input type="radio" id="radio3" name="get_type" value="0" /><label for="radio3">單獨發送</label>
					</span>
					</td>
	            </tr>
	            <tr class="send_phone" style="display:none;">
	                <td class="tablehead">用戶手機號</td>
	                <td><input type="text" name="phone" /></td>
	            </tr>
	            <tr>
	                <td class="tablehead"><input type="hidden" name="coupon_id"/></td>
	                <td><input type="button" name="confirm_send" class="confirm_send" value="确认" style="padding:6px 20px;"/></td>
	            </tr>
	        </table>
	    </form>
    </div>
    <div class="page">{$page}</div>
</div>
<script type="text/javascript">
    $(function() {
    	$('#radio2').click(function(){
    		$('.send_phone').hide();
    	});
    	$('#radio3').click(function(){
    		$('.send_phone').show();
    	});
    	$('.add_server_name').click(function(){
    		$('input[name=coupon_id]').val($(this).attr('coupon_id'));
    		art.dialog({
     			content: document.getElementById('add_name'),
    		});
    	});
        //$('select[name="search"]').val("{$Think.cookie.businessListSearch}");
    });


    $(".confirm_send").click(function(){
    	 var formData = new FormData($( "#upForm" )[0]);
    		$.ajax({
    			url:"{:U(MODULE_NAME.'/'.CONTROLLER_NAME.'/send_coupon')}",
    			type: 'POST',
    	        data : formData,
    	        async: false,
    	        cache: false,
    	        contentType: false,
    	        processData: false,
    			dataType: 'json',
    			success:function(data){
    				if (data.status == 1){
    	    			callBackTips(data.status, data.info,data.url);
    	    		}
    				else{
    	    			callBackTips(data.status, data.info);
    	    		}
    			}
    		});
    });
</script>
<include file="Common:footer" />
